1. Field of the Invention
The present invention relates to a method and device for filtering elements of a structured document on the basis of an expression, in particular an expression of XPath type.
2. Related Art
It has a general application in the processing of data streams in markup language and more particularly for files of XML format.
A document, according to the invention, comprises a plurality of elements structuring the data of the document, those elements being termed nodes in XML terminology.
The XPath language (acronym for “XML Path Language”) comes from a specification of the W3C consortium called “XPath Specification 1.0” presented at the address www.w3.org/TR/xpath. The objective of this language is to define a syntax adapted to address parts of a structured document of XML type.
The syntax of this language uses a similar syntax to that used in the expressions relative to LocationPaths in a file system, for example the expression relative to a LocationPath “/bookshop/book”.
The XPath language defines four types of data which are “string”, “Boolean”, “number” and “node-set”, seven types of nodes also termed elements, and expressions making it possible to manipulate the data, in particular the defined operators “equal”, “different”, “less than”, “greater than”, “plus”, “minus”, “multiply”, “divide”, “modulo”, “binary or” and “binary and”. Nodes may represent different types of XML event, for example the start of the document (also termed the root node), an XML element, an attribute, a text, a comment, a processing-instruction, and a namespace. This syntax enables the expression of requests in relation to structured documents, for the purpose, for example, of transforming them (for example the XSLT transformation according to the W3C recommendation defined at the address www.w3.org/TR/xslt), of fast accessing sub-parts (for example according to the W3C recommendation: XPointer: www.w3.org/TR/WD-xptr) or of carrying out processing on parts of the document (for example according to the XQuery 1.0 language, defined at the address www.w3.org/TR/xquery).
The XPath language makes it possible to simplify the development of applications suitable for going through data in structured documents of XML type.
The entity adapted to perform the evaluation of an XPath expression is called an XPath Processor. On the basis of an XPath expression and a reference to XML data stored in a document or received via a network transmission, the XPath Processor evaluates the expression.
The XPath syntax also defines a grammar describing the rules of construction for the different expression and sub-expressions. These expression are in particular expressions returning a Boolean (for example the expressions OrExpr, AndExpr, RelativeExpr, EqualityExpr), the expressions returning a number (for example AdditiveExpr, MultiplicativeExpr), the expressions returning any type of data (for example the expressions FilterExpr and Function Call), and the expressions returning an ordered list of nodes (for example the LocationPath expressions corresponding to the specification of a path to resolve in an XML document).